package com.huixuebao.exchange.controller.temp;


import com.huixuebao.exchange.dto.CategoryDTO;
import com.huixuebao.exchange.dto.CourseDTO;
import com.huixuebao.exchange.entity.BaseDivision;
import com.huixuebao.exchange.service.*;
import com.huixuebao.exchange.tempDto.TempUserDTO;
import com.huixuebao.common.bean.ApiResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/exchangeApi/temp/logic")
public class TempUserController {

    @Autowired
    TempUserService tempUserService;
    @Autowired
    MechanismService mechanismService;
    @Autowired
    CourseService courseService;
    @Autowired
    CategoryService categoryService;
    @Autowired
    BaseDivisionService baseDivisionService;

    @PostMapping("/addUser")
    public ApiResult addTempUser(@RequestBody TempUserDTO tempUserDTO){

        return tempUserService.addTempService(tempUserDTO);
    }

    @GetMapping("/getTempUserList")
    public ApiResult getTempUserList(@RequestParam Integer current, Integer size, String userName, String userMobile, String policyCode){

        return tempUserService.getTempUserList(current,size,userName,userMobile,policyCode);
    }
    /**
     * 获取机构列表信息
     * @param categoryId
     * @param brand
     * @param cityId 城市编码Id
     * @param axisX 经度
     * @param axisY 纬度
     * @param distance 距离（单位米）
     * @return com.huixuebao.common.bean.ApiResult
     */
    @GetMapping("/byDistance")
    public ApiResult<List<CourseDTO>> getAllCourse(Integer current,
                                                    Integer size,
                                                    String cityId,
                                                    Double axisX,
                                                    Double axisY,
                                                    Integer distance,
                                                    String categoryId,
                                                    String brand,
                                                    String courseName){
        return courseService.getAllCourse(current,size,cityId,axisX,axisY,distance,categoryId,brand,courseName);
    }

    /**
     * 课程分类数
     * @return
     */
    @GetMapping("/getCategoryTree")
    public ApiResult<List<CategoryDTO>> categoryTree(){
        return categoryService.categoryTree();
    }

    /**
     * 获取地区码树
     */
    @GetMapping("/getBaseDivisionTree")
    public ApiResult<List<BaseDivision>> getBaseDivisionTree(){
        return baseDivisionService.getAreaTree();
    }
    /**
     * 获取课程详情信息
     */
    @GetMapping("/getCourseContent")
    public ApiResult getCourseContent(String id){
        return courseService.getCourseContent(id);
    }
}
